<template>
  <div class="app-container">
    <!-- 搜索 -->
    <el-card class="search-card">
      <el-form size="small" :model="queryParams" class="formBox" label-width="88px">
        <el-row :gutter="0">
          <el-col :span="5">
            <el-form-item label="校区" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择校区"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="计划标题" prop="gradeId">
              <el-input
                placeholder="请输入计划标题"
                v-model="queryParams.gradeId"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="餐别名称" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="餐标名称" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="订餐月份" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="账单生效" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="使用状态" prop="gradeId">
              <el-select
                v-model="queryParams.status"
                placeholder="请选择使用状态"
                style="width: 100%"
              >
                <el-option value="1" label="开启"></el-option>
                <el-option value="2" label="关闭"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="供餐时间" prop="gradeId" class="width_100">
              <el-date-picker
                v-model="queryParams.value1"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="缴费时间" prop="gradeId" class="width_100">
              <el-date-picker
                v-model="queryParams.value1"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item>
              <div class="dis aic">
                <div class="flex_1"></div>
                <el-button
                  type="primary"
                  icon="el-icon-search"
                  size="mini"
                  @click="handleQuery"
                >
                  搜索
                </el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">
                  重置
                </el-button>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card class="search-card">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="buttonMethods(1)"
            v-hasPermi="['campus:unpaid:export']"
          >
            添加
          </el-button>
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleExport"
            v-hasPermi="['campus:unpaid:export']"
          >
            导出
          </el-button>
        </el-col>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
    </el-card>
    <el-card class="table-card">
      <el-table :data="dataList">
        <el-table-column label="商户名称" align="center" prop="idCardNumber" />
        <el-table-column label="开户行" align="center" prop="idCardNumber" />
        <el-table-column label="开户账号" align="center" prop="idCardNumber" />
        <el-table-column label="商编" align="center" prop="idCardNumber" />
        <el-table-column label="使用状态" align="center" prop="name">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status == 1">开启</el-tag>
            <el-tag v-if="scope.row.status == 2" type="danger">关闭</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="idCardNumber" />
        <el-table-column label="操作" align="center" width="200px">
          <template slot-scope="scope">
            <el-button
              type="warning"
              size="mini"
              class="padding_4_10"
              @click="buttonMethods(1, scope.row)"
              v-hasPermi="['campus:grade:edit']"
              >修改</el-button
            >
            <el-button
              type="danger"
              size="mini"
              class="padding_4_10"
              @click="buttonMethods(4, scope.row)"
              v-hasPermi="['campus:grade:remove']"
              >删除
            </el-button>
            <el-button
              :type="scope.row.status == 1 ? 'danger' : 'success'"
              size="mini"
              class="padding_4_10"
              @click="buttonMethods(5, scope.row)"
              v-hasPermi="['campus:grade:remove']"
            >
              <span v-if="scope.row.status == 1">关闭</span>
              <span v-if="scope.row.status == 2">开启</span>
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <el-dialog :title="title" :visible.sync="open" width="40%" append-to-body top="2vh">
      <el-form ref="form" :model="queryForm" label-width="120px">
        <el-form-item label="供应商名称" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入供应商名称"
            maxlength="30"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="开户行" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入开户行"
            maxlength="30"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="账户号" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入账户号"
            maxlength="30"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="商编" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入商编"
            maxlength="30"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="法人名称" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入法人名称"
            maxlength="30"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="联系电话" prop="gradeName" class="is-required">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入联系电话"
            maxlength="11"
            show-word-limit
          />
        </el-form-item>
        <el-form-item label="上传营业执照" prop="gradeName" class="is-required">
          <image-upload></image-upload>
        </el-form-item>
        <el-form-item label="食品经营许可证" prop="gradeName" class="is-required">
          <image-upload></image-upload>
        </el-form-item>
        <el-form-item label="备注" prop="gradeName">
          <el-input
            v-model="queryForm.gradeName"
            placeholder="请输入备注"
            maxlength="200"
            show-word-limit
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="buttonMethods(2)">确 定</el-button>
        <el-button @click="buttonMethods(3)">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { listGrade } from "@/api/campus/grade";
import { listClassManage } from "@/api/campus/classManage";

export default {
  name: "teamMealteamMealPlan",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 1,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      dataList: [
        {
          status: 1,
          name: "1",
        },
        {
          name: "2",
          status: 2,
        },
      ],
      campusList: [],
      gradeList: [],
      queryForm: {},
    };
  },
  created() {},
  activated() {},
  methods: {
    // 列表
    getList() {},
    /**
     * 按钮操作的方法
     *
     * @param options 操作选项，用于区分不同的按钮操作
     * @param value 按钮值
     */
    buttonMethods(options, value) {
      // 添加 修改
      if (options == 1) {
        if (value) {
          this.title = "修改供应商";
          this.queryForm = { ...value };
          this.open = true;
        } else {
          this.title = "添加供应商";
          this.queryForm = {};
          this.open = true;
        }
      }
      // 提交
      else if (options == 2) {
        var data = { ...this.queryForm };
        console.log(data);
      }
      // 关闭弹框
      else if (options == 3) {
        this.title = "";
        this.queryForm = {};
        this.open = false;
      }
      // 删除
      else if (options == 4) {
        this.$confirm("此操作将永久删除餐别, 是否继续?", "删除", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {})
          .catch(() => {});
      }
      // 关闭 开启
      else if (options == 5) {
        var str = value.status == 1 ? "关闭" : "开启";
        this.$confirm("此操作将" + str + "餐别, 是否继续?", str, {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {})
          .catch(() => {});
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 导出
    handleExport() {
      this.download(
        "",
        {
          ...this.queryParams,
        },
        `餐别管理导出.xlsx`
      );
    },
  },
};
</script>
<style>
.padding_4_10 {
  padding: 4px 10px !important;
}

.el-upload--picture-card {
  width: 90px !important;
  height: 90px !important;
  line-height: 90px !important;
}
</style>
